package com.jl.card.parse;

import java.util.Arrays;

import com.jl.util.HexUtil;

public class SimpleAnalyse {

	public static int sw(byte[] array) {
		if (array.length < 2) {
			throw new RuntimeException("length must be more than 2");
		}
		return HexUtil.makeInt(array, array.length - 2, 2);
	}

	public static int sw1(byte[] array) {
		if (array.length < 2) {
			throw new RuntimeException("length must be more than 2");
		}
		return array[array.length - 2];
	}

	public static int sw2(byte[] array) {
		if (array.length < 2) {
			throw new RuntimeException("length must be more than 2");
		}
		return array[array.length - 1];
	}

	public static byte[] data(byte[] res) {
		if (res.length < 2) {
			throw new RuntimeException("length must be more than 2");
		}
		return Arrays.copyOfRange(res, 0, res.length -2);
	}
}
